package com.shiyo.spring.basic_di.d_complexfield;

import com.shiyo.spring.basic_di.d_complexfield.bean.Bird;
import com.shiyo.spring.basic_di.d_complexfield.bean.Cat;
import com.shiyo.spring.basic_di.d_complexfield.bean.Dog;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class InjectComplexFieldAnnoApplication {

    public static void main(String[] args) throws Exception {
        //Autowired 三种注入方式
        ApplicationContext ctx = new AnnotationConfigApplicationContext("com.shiyo.spring.basic_di.d_complexfield");
        Dog dog = ctx.getBean(Dog.class);
        System.out.println(dog);

        //Resource相当于Autowired+Qualifier
        Bird bird = ctx.getBean(Bird.class);
        System.out.println(bird);

        //Inject搭配Named注入
        Cat cat = (Cat)ctx.getBean("cat");
        System.out.println(cat);
    }
}
